<template>
  <div>
    <button @click="normalRequest">普通请求</button>
    <button @click="customHeaderRequest">自定义header请求</button>
  </div>
</template>

<script>
import axios from "axios";

export default {
  name: "HTTPTest",
  methods: {
    normalRequest() {
      let formData = new FormData();
      formData.append("name", "jiankian")
      axios.post("http://localhost:8080/test/queryName", formData,).then((resp) => {
        console.log(resp)
      }).catch((err) => {
        console.log(err)
      })
        .finally(() => {
          console.log('normalRequest axios done')
        })
    },
    customHeaderRequest() {
      let formData = new FormData();
      formData.append("name", "jiankian")
      axios.post("http://localhost:8080/test/queryName", formData, {
        headers: {'Ann-Token': 'mycustom header value'}
      }).then((resp) => {
        console.log(resp)
      }).catch((err) => {
        console.log(err)
      })
        .finally(() => {
          console.log('normalRequest axios done')
        })
    }
  }
}
</script>

<style scoped>

</style>
